package com.zch.rpc.client.client;

import com.zch.rpc.client.common.entity.Person;
import com.zch.rpc.client.interfaces.HelloService;
import com.zch.rpc.client.interfaces.PersonService;
import com.zch.rpc.register.register.ServiceDiscovery;

/**
 * 用zookeeper服务注册跟发现的案例
 */
public class ClientProvider2 {
    public static void main(String[] args) {
        ServiceDiscovery serviceDiscovery = new ServiceDiscovery("localhost", 2181);//zookeeper的端口
        ServiceDiscovery serviceDiscovery2 = new ServiceDiscovery("localhost", 2181);//zookeeper的端口

        RpcClientProxy2 proxy1 = new RpcClientProxy2(serviceDiscovery);
        RpcClientProxy2 proxy2 = new RpcClientProxy2(serviceDiscovery2);

        //获取动态的代理对象。
        PersonService personService = proxy1.getProxy(PersonService.class);

        System.out.println(personService.getInfo());

        Person person = new Person();
        person.setAge(23);
        person.setName("Qjm");
        person.setSex("男");
        System.out.println(personService.printInfo(person));
        HelloService helloService =proxy2.getProxy(HelloService.class);
        System.out.println(helloService.hello("你好 世界，我是RPC"));

    }
}
